import request from '@/utlis/request.js';

export const queryDevicesInUse=(data) =>{
    return request.post('/devices/queryInUse',data);
}


/**
 * 获取设备列表
 * @param {Object} params 查询参数
 * @returns Promise
 */
export const queryDevices = (data) => {
    return request.post('/devices/query',data);
}

/**
 * 添加新设备
 * @param {Object} data 设备数据
 * @returns Promise
 */
export function registerDevice(data) {
    return request.post('/devices/register', data)
}

/**
 * 更新设备信息
 * @param {String} id 设备ID
 * @param {Object} data 更新数据
 * @returns Promise
 */
export function updateDevice(data) {
    return request.post('/devices/update', data)
}

/**
 * 删除设备
 * @param {String} id 设备ID
 * @returns Promise
 */
export function deleteDevice(data) {
    return request.post('/devices/delete', data)
}

/**
 * 导出设备列表
 * @param {Object} params 查询参数
 * @param {String} type 导出类型(excel/pdf)
 * @returns Promise
 */
export function exportDevice(params, type = 'excel') {
    return request({
        url: `/api/device/export/${type}`,
        method: 'get',
        params,
        responseType: 'blob' // 重要：接收二进制流
    })
}

/**
 * 获取设备状态选项
 * @returns Promise
 */
export function getDeviceStatusOptions() {
    return request({
        url: '/api/device/status-options',
        method: 'get'
    })
}

export const returnDeviceApi=(date)=>{
    return request.post('/devices/return',date)
}
